#include "AlgorithmLib.h"
#include <cmath>
using namespace std;

CAlgorithmLib::CAlgorithmLib(void)
{
}


CAlgorithmLib::~CAlgorithmLib(void)
{
}

double CAlgorithmLib::MA( double* d, int M )
{
  double ma = 0;
  for(int i = 0; i < M; ++i)
    ma += d[i];
  return ma /= M;
}

double CAlgorithmLib::STD( double* d, int M )
{
  double ma = MA(d, M);
  double std = 0;
  for(int i = 0; i < M; ++i)
  {
    std += (d[i]-ma)*(d[i]-ma);
  }
  return sqrt(std/M);
}

double CAlgorithmLib::SUM( double* d, int M )
{
  double sum = 0;
  for(int i = 0; i < M; ++i)
    sum += d[i];
  return sum;
}
